package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.domain.entity.BizProjectBudgetFee;
import com.project.domain.vo.BudgetFeeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ProjectBudgetFeeMapper extends BaseMapper<BizProjectBudgetFee> {
    @Select({
            "<script>",
            "select SUBJECT_CODE as id, FEE_RATIO as feeRatio,",
            "SUM(CASE WHEN BUDGET_TYPE = 'zhuanxiang' THEN SUBJECT_FEE ELSE 0 END) / 10000 AS zxMoney, ",
            "SUM(CASE WHEN BUDGET_TYPE = 'peitao' THEN SUBJECT_FEE ELSE 0 END) / 10000 AS ptMoney, ",
            "SUM(CASE WHEN BUDGET_TYPE = 'liuxiao' THEN SUBJECT_FEE ELSE 0 END) / 10000 AS lxMoney,  ",
            "SUM(CASE WHEN BUDGET_TYPE = 'waibo' THEN SUBJECT_FEE ELSE 0 END) / 10000 AS wbMoney, ",
            "SUM(CASE WHEN BUDGET_TYPE = 'zichou' THEN SUBJECT_FEE ELSE 0 END) / 10000 AS zcMoney,  ",
            "SUM(CASE WHEN BUDGET_TYPE = 'yfContract' THEN SUBJECT_FEE ELSE 0 END) / 10000 AS yfFee  ",
            "from biz_project_budget_fee bpbf where PROJECT_ID = '${proId}'",
            "group by SUBJECT_CODE, FEE_RATIO ",
            "</script>"
    })
    List<BudgetFeeVo> selectBudgetFeeInfo(@Param("proId") String proId);

    @Select({
            "<script>",
            "select FEE_AUTHORIZE as feeTotal from v_project where ID = '${proId}'",
            "</script>"
    })
    String getFeeTotal(@Param("proId") String proId);
}
